<?php

namespace App\Models\Conf;

use App\Models\Def\MainGamePlat;
use App\Models\User;
use Illuminate\Database\Eloquent\Model;

class Agent extends Model
{
    protected $table = 'conf_agents';

    protected $guarded = [];

    public function user()
    {
        return $this->belongsTo(User::class)->withTrashed();
    }

    public function sites()
    {
        return $this->hasMany(Site::class, 'agent_id');
    }

    public function mainGamePlats()
    {
        return $this->belongsToMany(
            MainGamePlat::class,
            'conf_agent_main_game_plats',
            'agent_id',
            'plat_id'
        )
            ->withPivot('rate')
            ->withTimestamps();
    }
}
